# coding: utf-8
from qfluentwidgets import QConfig, ColorConfigItem, ConfigItem, OptionsValidator, OptionsConfigItem, \
    BoolValidator, Theme, qconfig, RangeConfigItem, RangeValidator

from .settings import CONFIG_DIR
from .utils import isWin11
from .icon import SingleIcon


class Config(QConfig):
    """ Config of application """
    themeColor = ColorConfigItem("QFluentWidgets", "ThemeColor", '#9775fa')

    # main window
    micaEnabled = ConfigItem("MainWindow", "MicaEnabled", isWin11(), BoolValidator())
    dpiScale = OptionsConfigItem(
        "MainWindow", "DpiScale", "Auto", OptionsValidator([1, 1.25, 1.5, 1.75, 2, "Auto"]), restart=True)
    # 壁纸
    wallpaperEnabled = ConfigItem("Wallpaper", "Enabled", True, BoolValidator())
    wallpaperPath = ConfigItem("Wallpaper", "Path", SingleIcon.WALLPAPER.path())
    wallpaperBlurRadius = RangeConfigItem("Wallpaper", "BlurRadius", 6, RangeValidator(0, 40))
    wallpaperOpacity = RangeConfigItem("Wallpaper", "Opacity", 150, RangeValidator(0, 255))
    wallpaperLightMaskColor = ColorConfigItem("Wallpaper", "LightMaskColor", '#ffffff')
    wallpaperDarkMaskColor = ColorConfigItem("Wallpaper", "DarkMaskColor", '#000000')

    homePlugin = ConfigItem("Plugin", "Home", "包子漫画")


cfg = Config()
cfg.themeMode.value = Theme.AUTO
qconfig.load(CONFIG_DIR / 'config.json', cfg)
